import 'package:flutter/material.dart';

///
/// 纵向图文按钮
/// reverse：false=上图下文，true=上文下图
///
class QIconTitleVerticalButton extends GestureDetector {
  final bool reverse;
  final String iconPath;
  final String title;
  final double iconWidth;
  final double titleSize;
  final Function? callBack;

  QIconTitleVerticalButton({
    Key? key,
    required this.title,
    required this.iconPath,
    required this.iconWidth,
    required this.titleSize,
    this.reverse = false,
    this.callBack,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return GestureDetector(
        onTap: () {
          if (callBack != null) {
            callBack!();
          }
        },
        child: reverse
            ? Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Text(
                    title,
                    style:
                    TextStyle(fontSize: titleSize, color: Colors.black),
                  ),
                  const SizedBox(height: 10),
                  Image.asset(
                    iconPath,
                    width: iconWidth,
                    height: iconWidth,
                  )
                ],
              )
            : Column(
                children: [
                  Image.asset(
                    iconPath,
                    width: iconWidth,
                    height: iconWidth,
                  ),
                  const SizedBox(height: 10),
                  Text(
                    title,
                    style:
                    TextStyle(fontSize: titleSize, color: Colors.black),
                  ),
                ],
              ));
  }
}
